package comp418.blingo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.ObjectInputStream;

import messagePackage.ReturningMessage;
import android.os.NetworkOnMainThreadException;
import android.util.Log;
/**
 * This is the reader used to get the message from the server
 * @author LIU Jingbang
 *
 */
public class ReturningSocketReader extends Thread {
    BufferedReader serverin;
    String obj;
    
    ObjectInputStream ObjectIS = null;
    ReturningMessage readMessage=null;
    
    @SuppressWarnings("unused")
    private ReturningSocketReader() {
        // ��ʹ�õĽ�����
    	
    }
    
    ReturningSocketReader(BufferedReader in) {
            serverin = in;

    }
    
    ReturningSocketReader(ObjectInputStream ObjectIS) {
        this.ObjectIS = ObjectIS;
        
    }
 
    public void run() {
        
            try {
            	
				readMessage = (ReturningMessage)ObjectIS.readObject();
				Log.i("show",new Integer(readMessage.questionNum).toString());
				Log.i("show",readMessage.answerTextContent);
				
            } catch (IOException e) {
                e.printStackTrace();
                Log.i("Chat", "ioexption");
            } catch (ClassNotFoundException e){
            	Log.i("Chat", "cnfexption");
            } catch(Exception e){
            	
            	Log.i("Chat", "");
            }
            

            try {
                ReturningSocketReader.sleep(500);
            } catch (InterruptedException e) {
               Log.i("Chat", "Thread�Д��e�`");
                e.printStackTrace();
            }// ��Ϣ0.2��
        
 
    }
}
 